package demo3;

 abstract class Animal{
    public String name;
    public int age;

    public Animal(String name,int age){
        this.name=name;
        this.age=age;
    }

    public abstract void eat();

     public abstract void run();
 }

interface IFly{
     void fly();
}

interface IRun{
     void run();
}

interface ISwin{
     void swin();
}


class Dog extends Animal implements IRun{
     public Dog(String name,int age){
         super(name, age);
     }

    @Override
    public void eat() {
        System.out.println(this.name+"正在吃");
    }

    @Override
     public void run(){
         System.out.println(this.name+"正在跑");
     }
}

class Forg extends Animal implements IRun,ISwin{
     public Forg(String name,int age){
         super(name, age);
     }

    @Override
    public void eat() {
        System.out.println(this.name+"正在吃饭");
    }

    @Override
    public void run() {
        System.out.println(this.name+"蛙跳");
    }

    @Override
    public void swin() {
        System.out.println(this.name+"正在蛙泳");
    }
}

class Durck extends Animal implements IRun,ISwin,IFly{

    public Durck(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(this.name+"正在吃饭");
    }

    @Override
    public void run() {
        System.out.println(this.name+"正在用鸭脚跑");
    }

    @Override
    public void fly() {
        System.out.println(this.name+"正在飞");
    }

    @Override
    public void swin() {
        System.out.println(this.name+"正在游泳");
    }
}

class Roobt implements IRun{
    @Override
    public void run() {
        System.out.println("机器人正在跑");
    }
}

public class Test {

     public static void func1(Animal animal){
         animal.eat();
     }

     public static void running(IRun iRun){
         iRun.run();
     }



    public static void main(String[] args) {
        Animal animal = new Durck("可达鸭",18);
        animal.eat();

        func1(new Durck("唐老鸭",20));
        func1(new Dog("旺财",20));
        func1(new Forg("青蛙王子",20));

        running(new Dog("旺财",1));
        running(new Durck("可达鸭",1));
        running(new Forg("王子",1));
        running(new Roobt());
    }
}
